
    //去掉左右空格
    function trimBlankFunc(str){
        return str.replace(/^\s*|\s*$/g,"");
    }
    //键盘事件
    function getKeyCode(e){
        var keyNum = 0;
        try{
            if(window.event){ // IE
                keyNum = e.keyCode;
            }else if(e.which){ // Netscape/Firefox/Opera
                keyNum = e.which;
            }
        }catch (ex){}
        return keyNum;
    }
    //回车事件处理
    function treatKeyEvent(event){
        if(getKeyCode(event)==13){
            if (FrmCheck()) {
                submitLogin();
            }
        }
    }
    //验证管理员登陆信息
    function FrmCheck(){
        var flag=true;
        var loginName = trimBlankFunc($("#loginName").val());
        var password = trimBlankFunc($("#loginPwd").val());
        //密码加密
        
        if(loginName.length==0){
            $("#loginName").focus();
            flag=false;
        }else if(password.length==0){
            $("#loginPwd").focus();
            flag=false;
        }
        if(flag){
        	password = hex_md5(password);
            $("#loginPwd").val(password);
        }
        return flag;
    }
    //登录请求
    function submitLogin(){
        var jsonData = {
            loginName : $('#loginName').val(),
            loginPwd : $('#loginPwd').val()
        };
        $.ajax({
            async : false,
            cache : false,
            type : 'POST',
            url : projectUrl+"/login/check",// 请求的action路径
            data : jsonData,
            error : function() {// 请求失败处理函数
                $.msgbox("系统忙，请稍后再试！", {type: "error"});
            },
            success : function(data) {
                var d = data;
                if(d.success){
                    if(d.obj){
                        document.location.replace(projectUrl+"/frame/"+d.obj);
                    }else{
                        document.location.replace(projectUrl+"/frame/select");
                    }
                }else{
                    $.msgbox(d.msg, {type: "error"});
                }
            }
        });
    }